<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			div{
				width:800px;
				height:100px;
				padding:40px;
				border:1px solid black;
				margin:20px auto;
			}
			.price{
				float:right;
			}
			div button{
				float:right;
			}
		</style>
		
		<script>
			window.onload = function()
			{
				let btns = document.querySelectorAll('button');
				let divs = document.querySelectorAll('div');
				
				for(let i = 0; i < divs.length; i++)
				{
					btns[i].onclick = function()
					{
						if(confirm())
						{
							// divs[i].style.display = 'none';
							btns[i].parentNode.style.display = 'none';
							btns[i].parentNode.nextSibling.style.background = 'blue';
						}
					}
				}
			}
		</script>
	</head>
	<body>
		<div>
			<p>
				<span>铅笔</span>
				<span class="price">100</span>
			</p >
			<button>移出购物车</button>
		</div>
		<div>
			<p>
				<span>运动鞋</span>
				<span class="price">100</span>
			</p >
			<button>移出购物车</button>
		</div>
		<div>
			<p>
				<span>书包</span>
				<span class="price">100</span>
			</p >
			<button>移出购物车</button>
		</div>
		<div>
			<p>
				<span>钢笔</span>
				<span class="price">100</span>
			</p >
			<button>移出购物车</button>
		</div>
	</body>
</html>